#include<iostream>
#include<algorithm>
#include<vector>

using namespace std;



vector<int> div(vector<int> &A,int &b,int &r ){
	r=0;
	vector<int> C;
	for(int i=A.size()-1;i>=0;i--){
		A[i]+=r*10;
		C.push_back(A[i]/b);
		r=A[i]%b;

	}
	reverse(C.begin(),C.end());
	while(C.back()==0&&C.size()!=1) C.pop_back();
	return C;
}

int main(){
	freopen("input.txt","r",stdin);
	vector<int> A;
	int b;
	string a;
	cin>>a>>b;
	for(int i=a.length()-1;i>=0;i--){
		A.push_back(a[i]-'0');
	}

	int r;
	vector<int> C;
	C=div(A,b,r);
	for(int i=C.size()-1;i>=0;i--){
		printf("%d",C[i]);
	}

	printf(" %d\n",r);
}